package com.jtjrenren.android.taxi.passenger.core.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jtjrenren.android.taxi.passenger.R;
import com.jtjrenren.android.taxi.passenger.bean.api.ComplaintList;
import com.jtjrenren.android.taxi.passenger.base.BaseRcyAdapter;

/**
 * Created by Administrator on 2016/2/19.
 */
public class CompaintReplayAdapter extends BaseRcyAdapter<ComplaintList.ComplaintListEntity.ReplyListEntity> {

    public CompaintReplayAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerView.ViewHolder getItemViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_chat_complaint, parent, false);

        return new ReplyViewHolder(view);
    }

    @Override
    public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
        ComplaintList.ComplaintListEntity.ReplyListEntity info = list.get(position);

        ReplyViewHolder rholder = (ReplyViewHolder) holder;
        rholder.tv_date.setText(info.getReplyTime());
        if (Integer.parseInt(info.getReplyFrom()) == 0) {
            rholder.tv_left.setVisibility(View.VISIBLE);
            rholder.ll_right.setVisibility(View.GONE);

            rholder.tv_left.setText(info.getReplyContent());
        } else {
            rholder.tv_left.setVisibility(View.GONE);
            rholder.ll_right.setVisibility(View.VISIBLE);

            rholder.tv_right.setText(info.getReplyContent());

            if (info.isMainReplay()) {
                rholder.iv_frie.setVisibility(View.VISIBLE);
            } else {
                rholder.iv_frie.setVisibility(View.GONE);
            }
        }
    }

    public class ReplyViewHolder extends RecyclerView.ViewHolder {
        TextView tv_left, tv_right, tv_date;
        LinearLayout ll_right;
        ImageView iv_frie;

        public ReplyViewHolder(View itemView) {
            super(itemView);

            tv_date = (TextView) itemView.findViewById(R.id.item_chat_complaint_time);
            tv_left = (TextView) itemView.findViewById(R.id.item_chat_complaint_platform);
            tv_right = (TextView) itemView.findViewById(R.id.item_chat_complaint_self);
            ll_right = (LinearLayout) itemView.findViewById(R.id.item_chat_complaint_self_con);
            iv_frie = (ImageView) itemView.findViewById(R.id.item_chat_complaint_self_frie);
        }
    }
}
